package com.etc.controller;

import com.etc.common.CodeMessage;
import com.etc.pojo.EmpPojo;
import com.etc.servcie.EmpService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.List;

@Controller
@ResponseBody
public class EmpController {
    @Autowired
    EmpService service;

    @GetMapping("getAll")
    public CodeMessage faaaaO() {

        return CodeMessage.success(service.fsafa());
    }

    @PostMapping("emp")
    public CodeMessage addemp(EmpPojo emp) {
        service.add(emp);
        return CodeMessage.success(null);
    }

    @GetMapping("emp")
    public CodeMessage empsearchzonghechaxun(@RequestParam HashMap param) {
        List<HashMap> hmlist = service.xxxxx(param);

        hmlist.forEach(item -> {item.forEach((k,v)-> System.out.print(k + "@" +v + "\t"));System.out.println();});

        return CodeMessage.success(hmlist);
    }

}
